{template 'common/header'}
<ul class="nav nav-tabs">
 	<li {if $op == 'list'}class="active"{/if}><a href="{php echo $this->createWebUrl('CustomModel',array('op'=>'list'));}">证书管理</a> </li>
  	<li {if $op == 'add' }class="active"{/if}><a href="{php echo $this->createWebUrl('doCustom', array('op' => 'add'));}">添加证书</a> </li>    
 	{if $op == 'update' }
  	<li class="active" ><a href="#">编辑证书</a></li>
 	{/if}    
</ul>
{if $op =='list'}    
<div >
    <form id="form2" class="form-horizontal" action="{php echo $this->createWebUrl('customModel', array());}" method="post">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th class="row-first" width="150px">选择</th>
                <th width="150px">编号<i></i></th>
                <th style="text-align: center;">名称<i></i></th>
                <th style="text-align: center;">操作时间<i></i></th>
                <th style="text-align: center;">操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $list $k $v}
            <tr>
                <td>
                   <input type="checkbox" value="{$v['id']}" name="delete[]">
                </td>
				<td>{$v['id']}</td>
                <td style="text-align: center;">{$v['name']}</td>
                <td style="text-align: center;">{php echo  date('Y-m-d H:i:s', $v['add_time']);}</td>
                <td style="text-align: center;">
                    <a href="{php echo $this->createWebUrl('doCustom',array('op'=>'update','id'=>$v['id']));}" title="编辑" class="btn btn-mini btn-primary"><i class="fa fa-edit"></i></a>
                    <a onclick="return confirm('此操作不可恢复，确认吗？'); return false;" href="{php echo $this->createWebUrl('customModel', array('id' => $v['id'],'flag'=>'1'));}" title="删除" class="btn btn-mini btn-danger"><i class="fa fa-times"></i></a>
                </td>
            </tr>
            {/loop}
            </tbody>                　
        </table>
          <table class="table">
        <tr>
            <td >
                <input type="checkbox"  onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" name=''>
                <input class="btn btn-primary" type="submit" value="删除" name="submit" >
            </td>
        </tr>
      	</table>
    </form>
</div>
<script type="text/javascript">
    $('#form2').submit(function(){
        if($(":checkbox[name='delete[]']:checked").size() > 0){
            return confirm('删除后不可恢复，您确定删除吗？');
        }
        return false;
    }); 
</script>   
{elseif $op == 'add' || $op == 'update'}
<link href="./resource/css/app.css" rel="stylesheet" />
<link href="../addons/tim_welfare/template/mobile/css/colpick.css" rel="stylesheet" />

<script src="../addons/tim_welfare/template/mobile/js/colpick.js"></script>
<style>
.conditionMenu .app .app-preview:after {
     position: initial; 
     border:0px;
}
</style>
<div class="conditionMenu ng-scope" ng-controller="conditionMenuDesigner" id="conditionMenuDesigner">
	<div class="app clearfix">
		<div style="width: 335px;"> 
			&nbsp;&nbsp;&nbsp;			
			<div class="app-preview" style="width: 320px;border:0px;margin-top:-18px;top:0px">
				<div class="app-content" style="width: 320px;">  
					<div id='pic'>
						<img src="../addons/tim_welfare/template/mobile/img/bj1.jpg"  style="width: 318px;">
					</div>
				</div>
			</div>
		</div>		
		<div class="app-side" style="margin:0 0">
			<div class="menu app-conditionMenu-edit" style="width:525px;">
				<div class="arrow-left"></div>
				<div class="inner">					
					<div class="panel panel-default">
						<div class="panel-body form-horizontal">							
						    <form  id="mform" method="post"  action="{php echo $this->createWebUrl('doCustom',array());}">						
								<div class="conditionMenu-wx">
									<div class="card">
										<div class="nav-region">
											<div class="first-nav">										
												<div class="form-group">
													<label class="control-label col-xs-2">名称</label>
													<div class="col-xs-10">
														<input type="text"  name="name" value="{$cus['name']}" class="form-control ng-pristine ng-untouched ng-valid ng-empty" >
														<span class="help-block">用于区分</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-xs-2">背景图</label>
													<div class="col-xs-10">
														{php echo tpl_form_field_image('photo',$cus['photo']);}														
														<input class="btn btn-success btn-xs" type="bottom" value="图片预览" style="width:80px;" onclick="showimg();">
														<span class="help-block" style="display:inline-block">建议尺寸：750*1333</span>
													</div>
												</div>																	
												<div class="form-group">
													<label class="control-label col-xs-2">二维码</label>
													<div class="col-xs-10">
														{php echo tpl_form_field_image('ewm',$cus['ewm']);}
														<input class="btn btn-success btn-xs" type="bottom" value="图片预览" style="width:80px;" onclick="showimg();">
														<span class="help-block" style="display:inline-block">建议尺寸：240*240</span>
													</div>
												</div>
												<div class="form-group">
													<label class="control-label col-xs-2">印章</label>
													<div class="col-xs-10">
														{php echo tpl_form_field_image('logo',$cus['logo']);}
														<input class="btn btn-success btn-xs" type="bottom" value="图片预览" style="width:80px;" onclick="showimg();">
														<span class="help-block" style="display:inline-block">建议尺寸(png)：100*100</span>
													</div>													
												</div>
												<div class="form-group">
													<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">内容一</label>
													<div class="col-sm-8">
														<textarea name="content1" rows="3" cols="20" style="width:385px">{$cus['content1']}</textarea>
													</div>
												</div>
												<div class="form-group">
													<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">内容二</label>
													<div class="col-sm-8">
														<textarea name="content2" rows="3" cols="20" style="width:385px">{$cus['content2']}</textarea>
														<span class="help-block">建议字节长度控制在300字节内</span>
													</div>
												</div>
												<div class="form-group">
													<label class="col-xs-12 col-sm-2 col-md-2 col-lg-2 control-label">内容三</label>
													<div class="col-sm-8">
														<textarea name="content3" rows="3" cols="20" style="width:385px">{$cus['content3']}</textarea>
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>									
								<div class="form-group" style="margin-left: 400px; margin-top: 20px;">
			                    	<label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
			                    	<div class="col-sm-4">
			                    	  	<input type="hidden" name="token" value="{$_W['token']}" />
		                      		  	{if $op == 'add' }
				                      	<input name="add" type="submit" value="提交" class="btn btn-primary span3" />
					                  	{elseif $op == 'update'}
					                  	<input type="hidden" name="id" value="{$cus['id']}" / >
			                          	<input name="update" type="submit" value="提交" class="btn btn-primary span3" />
				                     	{/if}
			                    	</div>
		           			 	</div>
							</form>		
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script>				      
    $(document).ready(function(){
		$(window).scroll(function(){
			$(".app-preview").css("position","fixed");
		    if($(".app-preview").offset().top<=200){
		     	$(".app-preview").css("position","inherit");
		    }
		});
	});
								      
   	function showimg(){
		var createUrl='{php echo $this->createWebUrl("customImg", array()) }';
 	    var url=createUrl+"&"+$("#mform").serialize();
 		$("#pic").html('<img  src="'+url+'" style="width: 318px;" alt="努力加载中，请稍等">');
	}
  
  	if("{$cus['id']}"!=''){
 	 	showimg()
   	}
                     
	$('textarea').bind('input propertychange', function() { 
		showimg();
	});
		
</script>
{/if}

						
						